﻿CREATE PROCEDURE [dbo].[proc_Project_Task_Getlist_ProAll]
	(
		@ProjectId uniqueidentifier
	)
AS
begin
	;WITH list As(Select ROW_NUMBER() OVER (ORDER BY id)AS Row
		,Id
		,FId
		,TaskId
		,OrderId
		,ProjectId
,ProductId
		,CusName
		,Title
		,Description
		,DownPerson
		,DownPersonName
		,StartDate
		,ISNULL(EndDate,'1900-01-01') As EndDate
		,ExecDepartmentId
		,ExecDepartmentName
		,ExecPersonName
		,datediff(day,StartDate,ISNULL(EndDate,GetDate())) As CountDay
		,IsFinish
		,CompanyId
,TypeId
		,(Select Count(Id) From Project_Task p Where p.FId=Project_Task.TaskId) As ChildCount
		From Project_Task
		Where ProjectId=@ProjectId
	)
	Select * From list Order by Row
end
